package com.google.code.maven_plugin_tutorial.util.stub;

import java.io.File;
import java.io.FileReader;
import java.util.List;

import org.apache.maven.model.Developer;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;

public class PrintDeveloperPluginsProjectStub extends MavenProjectStub {
	public PrintDeveloperPluginsProjectStub() {
		File pom = new File(getBasedir(), "plugin-config.xml");
		MavenXpp3Reader pomReader = new MavenXpp3Reader();
		Model model = null;

		try {
			model = pomReader.read(new FileReader(pom));
			setModel(model);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}

		setGroupId(model.getGroupId());
		setArtifactId(model.getArtifactId());
		setVersion(model.getVersion());
		setName(model.getName());
		setUrl(model.getUrl());
		setPackaging(model.getPackaging());
		setFile(pom);
	}

	@Override
	public List<Developer> getDevelopers() {
		return getModel().getDevelopers();
	}

	/**
	 * @see org.apache.maven.plugin.testing.stubs.MavenProjectStub#getBasedir()
	 */
	@Override
	public File getBasedir() {
		return new File(super.getBasedir() + "/src/test/resources/");
	}
}
